<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>查询订单</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/st/back/css/base.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/st/back/css/iconfont.css">
    <script type="text/javascript" src="${pageContext.servletContext.contextPath}/st/front/JS/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/st/back/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.servletContext.contextPath}/st/back/layui/layui.js"></script>

    <style>
        .layui-table img {
            max-width: none;
        }
    </style>

</head>

<body>
<div class="cBody">
    <div class="console">
        <form class="layui-form" action="${pageContext.servletContext.contextPath}/getOrderClass" method="get">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <select name="lx">
                        <option value="-1">请选择</option>
                        <option value="0">已取消</option>
                        <option value="1">未付款</option>
                        <option value="2">已付款</option>
                        <option value="3">已发货</option>
                        <option value="4">已收货</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="name" required lay-verify="required" placeholder="输入订单编号"
                           autocomplete="off" class="layui-input">
                </div>
                <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
            </div>
        </form>

        <script>
            layui.use('form', function () {
                var form = layui.form;

                //监听提交
                form.on('submit(formDemo)', function (data) {
                    layer.msg(JSON.stringify(data.field));
                    return true;
                });
            });
        </script>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>订单编号</th>
            <th>收货人</th>
            <th>下单时间</th>
            <th>订单状态</th>
            <th>购买用户</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${page.list}" var="bill">
            <tr>
                <td>${bill.bid}</td>
                <td>${bill.aname}</td>
                <td><fmt:formatDate value="${bill.billtime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td>
                    <c:if test="${bill.billstate==0}">
                        已取消
                    </c:if>
                    <c:if test="${bill.billstate==1}">
                        未支付
                    </c:if>
                    <c:if test="${bill.billstate==2}">
                        已支付
                    </c:if>
                    <c:if test="${bill.billstate==3}">
                        已发货
                    </c:if>
                    <c:if test="${bill.billstate==4}">
                        已完成
                    </c:if>
                </td>
                <td>${bill.uname}</td>
                <td>
                    <button class="layui-btn layui-btn-xs" onclick="updateBut(${bill.bid})">查看订单</button>
                    <c:if test="${bill.billstate==2}">
                        <button class="layui-btn layui-btn-xs" onclick="specificationsBut(${bill.bid})">订单发货</button>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <!-- layUI 分页模块 -->
    <div id="pages" style="text-align: center">
        <!--显示页数-->
        <c:forEach var="pageNo" items="${page.navigatepageNums}">
            <c:choose>
                <c:when test="${pageNo == page.pageNum}">
                    <span class="numbers current" data-v-0acc30d3="">${pageNo}</span>
                </c:when>
                <c:otherwise>
                    <a class="numbers" data-v-0acc30d3="" href="${pageContext.servletContext.contextPath}/OrderAll?currentPageNo=${pageNo}" stat_exposure="true">${pageNo}</a>
                </c:otherwise>
            </c:choose>
        </c:forEach>
    </div>
    <script>

        //修改规格
        function specificationsBut(bid) {
            layui.use('layer', function () {
                var layer = layui.layer;

                //iframe层-父子操作
                layer.open({
                    type: 2,
                    area: ['70%', '60%'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: '${pageContext.servletContext.contextPath}/toOrderInfo/'+bid
                });
            });

        }

        //修改按钮
        var updateFrame = null;

        function updateBut(bid) {
            layui.use('layer', function () {
                var layer = layui.layer;

                //iframe层-父子操作
                updateFrame = layer.open({
                    title: "商品信息修改",
                    type: 2,
                    area: ['70%', '60%'],
                    scrollbar: false,	//默认：true,默认允许浏览器滚动，如果设定scrollbar: false，则屏蔽
                    maxmin: true,
                    content: '${pageContext.servletContext.contextPath}/back_billInfo/'+bid
                });
            });

        }
    </script>
</div>
</body>

</html>